﻿using AutoMapper;
using seejee_Backendium.Core.Dtos;
using seejee_Backendium.Core.Models;

namespace seejee_Backendium.Core.Mapping
{
    public class MenuProfile : Profile
    {
        public MenuProfile()
        {
            CreateMap<Menu, MenuDto>()
                .ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Title ?? string.Empty))
                .ForMember(dest => dest.Icon, opt => opt.MapFrom(src => src.Icon ?? string.Empty))
                .ForMember(dest => dest.Index, opt => opt.MapFrom(src => src.Index ?? string.Empty))
                .ForMember(dest => dest.RoutePath, opt => opt.MapFrom(src => src.RoutePath ?? string.Empty))
                .ForMember(dest => dest.GroupName, opt => opt.MapFrom(src => src.GroupName ?? string.Empty))
                .ForMember(dest => dest.ParentTitle, opt => opt.MapFrom(src => src.Parent != null ? src.Parent.Title : string.Empty))
                .ForMember(dest => dest.Children, opt => opt.MapFrom(src => src.Children))
                .ReverseMap();
        }
    }
}